package cn.jdy.common.util;

/**
 * 会员积分等级计算
 *
 * @author wuzhiliang
 */
public class ScoreRuleUtil {


	/**
	 * 等级计算 直接判断 6级
	 *
	 * @param startScore
	 * @param level
	 * @param endScore
	 * @return
	 */
	public static int getlevel(int score) {
		int level = 0;
		if(0 <= score && score < 99) {
			level = 1;
		} else if(100 <= score && score < 279) {
			level = 2;
		} else if(280 <= score && score < 649) {
			level = 3;
		} else if(650 <= score && score < 1049) {
			level = 4;
		} else if(1050 <= score && score < 1499) {
			level = 5;
		} else if(1500 <= score) {
			level = 6;
		}
		return level;
	}

	/**
	 * 等级计算 递归
	 *
	 * @param startScore
	 * @param level
	 * @param endScore
	 * @return
	 */
	public static int getlevel(int startScore, int level, int endScore) {
		int a = 20, b = 10;
		startScore = a + b * level + startScore;
		if(startScore > endScore) {
			return level;
		}
		level++;
		level = getlevel(startScore, level, endScore);
		return level > 20 ? 20 : level;
	}
}
